package view;

import java.util.ArrayList;
import java.util.List;

public class DataList<T> {
    private ArrayList<T> list;
    private int index;

    public static <T> DataList<T> createList() {
        return new DataList<T>();
    }
    public static <T> DataList<T> getList(ArrayList<T> list) {
        return new DataList<T>(list);
    }

    public DataList() {
        list = new ArrayList<T>();
        index = 0;
    }
    public DataList(ArrayList<T> list) {
        this.list = list;
        this.index = 0;
    }

    public void add(T obj) {
        list.add(obj);
    }

    public T next() {
        try {
            return list.get(index++);
        } catch (IndexOutOfBoundsException e) {
            // e.printStackTrace();
            return null;
        }
    }
}
